package com.edu.exam.enums;

/**
 * 监考安排冲突状态枚举
 *
 * <p>定义监考安排冲突的处理状态，包括待解决、解决中、已解决、无法解决、已忽略和已上报。</p>
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-12
 */
public enum AssignmentConflictStatus {
    PENDING("PENDING", "待解决"),
    IN_PROGRESS("IN_PROGRESS", "解决中"),
    RESOLVED("RESOLVED", "已解决"),
    CANNOT_RESOLVE("CANNOT_RESOLVE", "无法解决"),
    IGNORED("IGNORED", "已忽略"),
    ESCALATED("ESCALATED", "已上报");

    private final String code;
    private final String description;

    AssignmentConflictStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
    /**
     * 根据代码查找枚举值
     *
     * @param code 枚举代码
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果代码不存在
     */
    public static AssignmentConflictStatus fromCode(String code) {
        for (AssignmentConflictStatus status : AssignmentConflictStatus.values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown assignment conflict status code: " + code);
    }

    /**
     * 根据描述查找枚举值
     *
     * @param description 枚举描述
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果描述不存在
     */
    public static AssignmentConflictStatus fromDescription(String description) {
        for (AssignmentConflictStatus status : AssignmentConflictStatus.values()) {
            if (status.description.equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown assignment conflict status description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}